import Vue from "vue";
import App from "./App";
import "./uni.promisify.adaptor";
import store from "../store";
import Cache from "../utils/cache";
import util from "../utils/util";
import configs from "./config/app.js";

import uView from "uview-ui";
Vue.use(uView);

Vue.prototype.$util = util;
Vue.prototype.$config = configs;
Vue.prototype.$Cache = Cache;
Vue.prototype.$eventHub = new Vue();
Vue.config.productionTip = false;


App.mpType = "app";


Vue.mixin({
  methods: {
    setData: function(obj) {
      let that = this;
      let keys = [];
      let val, data;
      Object.keys(obj).forEach(function(key) {
        keys = key.split('.');
        val = obj[key];
        data = that.$data;
        keys.forEach(function(key2, index) {
          if (index + 1 == keys.length) {
            that.$set(data, key2, val);
          } else {
            if (!data[key2]) {
              that.$set(data, key2, {});
            }
          }
          data = data[key2];
        })
      });
    }
  }
});

const app = new Vue({
  ...App,
  store,
  Cache,
});
app.$mount();
